<?php
session_start();
ob_start();
include_once dirname(dirname(__FILE__)) . '/include/common.php';
$page = isset($_POST["page"]) ? intval($_POST["page"]) : 2;
$category_id = isset($_POST["category_id"]) ? intval($_POST["category_id"]) : 0;
$page = $page + 1;
$core = new core();
$load_more = 0;
$total =0;
$list_product = $core->getCrawlProductListByCategory($category_id,$page, $load_more,$total);
$html = '';

if ($list_product) {
    foreach ($list_product as $product) {

        $html.='  <tr>
                                                    <td>
                                                        '. $product->product_name.'
                                                        <p>'. $product->product_code.'</p>
                                                        <p><a href="'. $product->link_web.'">Link web</a></p>
                                                    </td>
                                                    <td class="center">
                                                        <img class="photo_product" style="width: 100px;" src="tmp_photo_crawl/'. $product->thumb_main_photo.'" rel="tmp_photo_crawl/'. $product->main_photo.'"/>
                                                    </td>
                                                    <td class="center">';

                                                        $list_extra_photo = explode(",",$product->thumb_extra_photo);
                                                        foreach($list_extra_photo as $extra_photo){
                                                            if($extra_photo!=''){

                                                                $html.='<img class="photo_product" style="width: 50px;" src="tmp_photo_crawl/'. $extra_photo.'" rel="tmp_photo_crawl/'. $extra_photo.'"/>';

                                                            }
                                                        }

                                                    $html.='</td>
                                                    <td class="center">
                                                        '. $product->stamp_price." / ".$product->store_price.'
                                                    </td>
                                                    <td class="center">'. $product->product_size.'</td>

                                                    <td class="center">'. $product->product_color.'</td>

                                                </tr>';
    }
}
echo json_encode(array('type' => 0, 'html' => $html, 'page' => $page, 'load_more' => $load_more,'total'=>$total));
die;
?>